• Image placeholder
  • 홈 페이지
  • 블로그 센터
  • 범주
Image placeholder

JPA 프로그래밍 - 기본편

영속성 전이와 고아 객체

특정 엔티티를 영속 상태로 만들 때 연관된 엔티티도 함께 영속상태로 만들도 싶을 때 사용한다 예) 부모 엔티티를 저장할 때 자식 엔티티도 함께 저장. @OneToMany(mappedBy="parent", cascade = CascadeType.PERSIST) 영속성 전이를 안해주면 자식의 개수만큼 em.persist(child);를 해야한다. 👉 cascade = CascadeType.ALL...

JPA 프로그래밍 - 기본편김영한JPA 프로그래밍 - 기본편

영속성 컨택스트 - 내부 동작 방식

👉 EntityManager 속 영속성 컨택스트 안에 member 객체가 들어가서 영속 상태가 된다. 👉 그럼 DB에서 조회하여 member2 객체를 1차 캐시에 저장한다. em.persist(member); 에서 1차 캐시에 "key=101" : "value=member" 가 저장된다 em.find(Member.class, 101L); 코드가 실행되면 DB에서 조회하기 전에 1차 캐시에서 ...

JPA 프로그래밍 - 기본편김영한JPA 프로그래밍 - 기본편

© 2022 intrepidgeeks.com

Privacy Policy Contact US Sitemap
🍪 This website uses cookies to ensure you get the best experience on our website. Learn more